<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="net.ssta.common.LoginUser" %>
<%@ page import="net.ssta.util.bill.UserPoint" %>
<%@ page import="net.ssta.util.bill.UserBill" %>
<%@ page import="net.ssta.util.bill.UserBillException" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String channel="2243";

String userId=LoginUser.getUserId();
if(userId==null){
	out.println("用户未登录！");
	return;
}
UserBill bill=new UserBill();
bill.initBillByRequest(request);
bill.setChannelId(channel);
bill.setInfoId("a1234");
try{
	new UserPoint(userId).chargeCms(bill);
}catch(UserBillException e){
	if(UserBillException.pointNotEnough.equals(e.getErrorCode())){
		out.println("用户积分不足，请充值");
		return;
	}
	else{
		out.println("扣费出错，请重新试"+e);
		return;
	}
}catch(Exception e){
	out.println("扣费出错，请重新试"+e);
	return;
}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'charge.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    This is my JSP page. <br>
  </body>
</html>
